/***************************************************
 @Name :        小铭同学
 @Time :        2025-09-03
 @Email :       LiaoMingWJ233@163.com
 @Comment :     TCP服务器
 @FileName :    tcp.h
 @Version :     1.0
****************************************************/


#ifndef TCP_H
#define TCP_H

#include <QWidget>
#include <QtNetwork>
#include <QTcpServer>
#include <QTcpSocket>
#include <QMessageBox>
#include <QDebug>

#include <QDateTime>
#include <QKeyEvent>
#include <QFocusEvent>

#include <QPixmap>


class TCP : public QWidget
{
    Q_OBJECT
public:
    explicit TCP(QWidget *parent = nullptr);
    
    QTcpServer *tcpServer;
    QTcpSocket *clientSocket;
    QList<QTcpSocket*> clientSockets;
    QTextCodec *m_gbkCodec;   
    
    int a=0;
    int b=0;
    
    void startServer();
    void stopServer();
    
    QString onReadyRead();
    void onSendButtonClicked(QString message);
    void onClientDisconnected();
    
private slots:
    void onNewConnection();            
    
signals:

    void statusChanged();
    void statusChanged_b();
    
    // 数据接收信号
    void dataReceived(const QString &data);
};

#endif // TCP_H
